<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>EOS易道运营系统</title>
<link href="css/themes/css/login.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.7.1.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#subBtn").click(function(){
		    signIn(); return false;
		});
		$("#validCode").keydown(function(ev) {
			ev = ev || event;
			if(isEnter(ev)) signIn();
		});
	});
	
	function signIn(){
		 var uname = $("#username").val();
	     var pwd = $("#password").val();
	     var code = $("#validCode").val();
	     if($.trim(uname) == ""){
	     	$("#errDiv").html("请输入帐号!").css({"color": "#f00", "font-size": "14px"});
	     	return;
	     }
	     if($.trim(pwd) == ""){
	     	$("#errDiv").html("请输入密码!").css({"color": "#f00", "font-size": "14px"});
	     	return;
	     }
	     if($.trim(code)== ""){
	     	$("#errDiv").html("请输入验证码!").css({"color": "#f00", "font-size": "14px"});
	     	return;
	     }
	     $("#errDiv").html("");
	     $("#loginForm").submit();
	}
	function refresh(target){
		var url="validCode?offset="+Math.random();
		$("#"+target).attr("src",url);
	}
	function isEnter(ev) {
	    ev = ev || window.event;
	    var code = ev.keyCode || ev.which;
	    return code == 10 || code == 13;
	}
	function SetHome() {
	    var locationHref = window.document.location.href; 
	    var pathName = window.document.location.pathname;   
	    var pos = locationHref.indexOf(pathName);  
	    var localhostPaht = locationHref.substring(0, pos);  
	    var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);  
	    try {
            this.style.behavior = "url(#default#homepage)";
            this.setHomePage(localhostPaht+projectName+'/login');
        } catch (e) {
            if (window.netscape) {
                try {
                    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                } catch (e) {
                    alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
                    return false;
                }
                var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
                prefs.setCharPref('browser.startup.homepage', localhostPaht+projectName+'/login');
            }
        }
        return false;
	 }
	function addFav(){
		var locationHref = window.document.location.href; 
	    var pathName = window.document.location.pathname;   
	    var pos = locationHref.indexOf(pathName);  
	    var localhostPaht = locationHref.substring(0, pos);  
	    var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);  
	    var ctrl = (navigator.userAgent.toLowerCase()).indexOf('mac') != -1 ? 'Command/Cmd' : 'CTRL';  
	    if (document.all) {  
			window.external.addFavorite(localhostPaht+projectName+'/login', 'EOS易道运营系统')  ;
	    } else if (window.sidebar) {  
			window.sidebar.addPanel('EOS易道运营系统', localhostPaht+projectName+'/login', "") ; 
	    }else{
			alert('添加失败\n您可以尝试通过快捷键' + ctrl + ' + D 加入到收藏夹~');  
	    } 
	}
</script>
</head>

<body>
	<div id="login">
		<div id="login_header">
			<h1 class="login_logo">
				<a href="http://www.e-sto.com.cn" target="_blank"><img src="css/themes/default/images/login_logo.gif" /></a>
			</h1>
			<div class="login_headerContent">
				<div class="navList">
					<ul>
						<li><a href="javascript:;" onclick="SetHome()">设为首页</a></li>
						<li><a href="javascript:;" onclick="addFav()">添加收藏</a></li>
					</ul>
				</div>
				<h2 class="login_title"><img src="css/themes/default/images/login_title.png" /></h2>
			</div>
		</div>
		<div id="login_content"> 
			<div class="loginForm"> 
				<form action="validateLogin" id="loginForm" method="post">
					<p>
						<label>邮箱：</label>
						<input type="text" name="email" id="username" size="20" class="login_input" maxlength="32" value="business@e-sto.com.cn" />
					</p>
					<p>
						<label>密码：</label>
						<input type="password" name="password" id="password" size="20" class="login_input" value="123456" maxlength="16" />
					</p>
					<p>
						<label>验证码：</label>
						<input class="code" style="ime-mode:disabled" type="text" name="validCode" id="validCode" size="6" maxlength="4" />
						<span><img src="validCode" style="cursor: pointer;" id="imgCode" title="看不清,换一张" alt="看不清,换一张" width="78" height="24" onclick="refresh('imgCode');" /></span>
					</p>
					<div class="login_bar">
						<input class="sub" type="button" id="subBtn" value="" />
					</div>
					<div id="errDiv" style="padding: 5px;">
					<s:if test="null != message">
						<span style="color:#f00;font-size:14px;">
							<s:property value="message" />
						</span>
					</s:if>
					</div>
				</form>
			</div>
			<div class="login_banner"><img src="css/themes/default/images/login_banner.jpg" /></div>
			<div class="login_main">
				<ul class="helpList">
					<li><a href="#">下</a></li>
					<li><a href="#">如何？</a></li>
					<li><a href="#">忘记密码怎么办？</a></li>
					<li><a href="#">为什么登录失败？</a></li>
				</ul>
				<div class="login_inner">
					<p>欢迎使用佣金核算系统 </p> 
				</div>
			</div>
		</div>
		<div id="login_footer">
			Copyright(C) 2013-2014 <a href="http://www.e-sto.com.cn" style="color: rgb(102, 102, 102);text-decoration: none;">深圳易道现代物流有限公司</a> All Rights Reserved 粤ICP备12040199号
		</div>
	</div>
</body>
</html>